$(function(){
//	获取个人信息
	personal_data(2);
//	获取申请信息
	$.ajax({
		type: "post",
		url: url + '/api.php/Up/getApplyInfo',
		data: {"token":token},
		dataType: 'json',
		success: function(result) {
			if(result.code == '0000') {
				var data=result.data;
				
//				是否可以申请
				if(data.apply_status == "0"){
					$(".sq_btn").attr("data","0");
					$(".level_name").html(data.apply_info.level_after_name);
				}else if(data.apply_status == "1"){
					$(".sq_btn").attr("data","1");
					$(".level_name").html(data.next_level_info.level_name);
				}else{
					$(".sq_btn").attr("data","2");
					$(".level_name").html("已是最高等级")
				}
				
//				是否正在申请中
				if(data.is_apply == "1"){
					$(".sq_btn").html("正在申请");
					dialog('#d3');
				}
				
				
				
			}else{
				isErr(result);
			}
		},
		error: function(XMLHttpRequest, textStatus, errorThrown) {
			alert("请求失败：" + XMLHttpRequest.status);
		}
	});
	
//	申请升级接口
	$(".sq_btn").on("click",function(){
		if($(this).attr("data") == "1"){
			$.ajax({
				type: "post",
				url: url + '/api.php/Up/apply',
				data: {"token":token},
				dataType: 'json',
				success: function(result) {
					if(result.code == '0000') {
						location.href='Application_submission.html?v=2019';
					}else{
						isErr(result);
					}
				},
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					alert("请求失败：" + XMLHttpRequest.status);
				}
			});
		}else if($(this).attr("data") == "2"){
			alert("已是最高等级不可申请");
		}
	})
	
})

